<!--
  - create_createaccount.php
  - v0.01
  - 2/1/2011 
  -
  - This source code calls the InsertNewAnalysis() method which determines if
  -	the parameters are inserted to the database correctly. This redirects to a
  -	success page if the insertion is successful, else, it will return to the
  - create analysis page, generating an error.
  -->
<?php
 	require 'libraries/AddAnalysisLib.php';
 	require 'libraries/UserLibrary.php';
	session_start();
	checkSessionVariable("administrator", "AdministratorHomepage.php", NULL);
	
	$CaslNo =  $_POST['CaslNo'];
	$PreparedBy = $_POST['PreparedBy'];
	$ClientName =  $_POST['ClientName'];
	$ClientCompany =  $_POST['ClientCompany'];
	$ClientAddress =  $_POST['ClientAddress'];
	$ClientTelfax =  $_POST['ClientTelfax'];
	
	/*Insert into the new analysis into the database.*/
	$create = InsertNewAnalysis($ClientName, $ClientCompany, $ClientAddress,
			$ClientTelfax, $CaslNo, $PreparedBy, "casl", "localhost",
			"createanalysis","createanalysis");
	
	/*Check if the analysis was inserted or not.*/
	if($create == TRUE){
		$_SESSION['caslnum'] = $CaslNo;
		header("Location: AddSample.php");
	}else{
		echo '<script type= "text/javascript"> alert("An error has occured");</script>';
		header("Location: createAnalysis.php?error=true");
	}
?>